﻿Public Class Parser
	Public Shared Function ParseDouble(number As String) As Double?
		If String.IsNullOrEmpty(number) Then Return Nothing

		Return Double.Parse(number, System.Globalization.CultureInfo.InvariantCulture)
	End Function

	Public Shared Function ParseEnum(Of T)(value As String) As Object
		If String.IsNullOrEmpty(value) Then Return Nothing

		Return [Enum].Parse(GetType(T), value)
	End Function

	Public Shared Function ParseBoolean(value As String) As Nullable(Of Boolean)
		If String.IsNullOrEmpty(value) Then Return Nothing

		Return CBool(value)
	End Function

	Shared Function ParseDate(value As String) As Date?
		If String.IsNullOrEmpty(value) Then Return Nothing

		Return DateTime.Parse(value, System.Globalization.CultureInfo.InvariantCulture)
	End Function

End Class
